
//If the time is less than 10, you will get a "Buenos dias" greeting.
//Otherwise you will get a "Feliz dia" greeting.
function saludo () 
{
    var d = new Date();
    var time = d.getHours();

    if (time < 12)
    {
        return("<b>&iexcl;BUENOS D&Iacute;AS!</b>");
    }
    else if (time>=12 && time<18)
    {
        return("<b>&iexcl;BUENAS TARDES!</b>");
    }
    else
    {
        return("<b>&iexcl;BUENAS NOCHES!</b>");
    }
}

//Mostrar la hora actual
function hora(){
    var fecha = new Date()
    var hora = fecha.getHours()
    var minuto = fecha.getMinutes()
    var segundo = fecha.getSeconds()
    if (hora < 10) {
        hora = "0" + hora
    }
    if (minuto < 10) {
        minuto = "0" + minuto
    }
    if (segundo < 10) {
        segundo = "0" + segundo
    }
    var horita = hora + ":" + minuto + ":" + segundo
    document.getElementById('hora').firstChild.nodeValue = horita
    tiempo = setTimeout('hora()',1000)
}
function inicio(){
    document.write ('<span id="hora">')
    document.write ('000000</span>')
    hora()
}

//Metodo que valida el ingreso correcto de Email
function validateEmail(form) {
    var bValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();

    var oEmail = eval('new ' + jcv_retrieveFormName(form) +  '_email()');

    for (var x in oEmail) {
        if (!jcv_verifyArrayElement(x, oEmail[x])) {
            continue;
        }
        var field = form[oEmail[x][0]];
        if (!jcv_isFieldPresent(field)) {
            continue;
        }
        if ((field.type == 'hidden' || 
            field.type == 'text' ||
            field.type == 'textarea') &&
        (field.value.length > 0)) {
            if (!jcv_checkEmail(field.value)) {
                if (i == 0) {
                    focusField = field;
                }
                fields[i++] = oEmail[x][1];
                bValid = false;
            }
        }
    }
    if (fields.length > 0) {
        jcv_handleErrors(fields, focusField);
    }
    return bValid;
}

/**
     * Reference: Sandeep V. Tamhankar (stamhankar@hotmail.com),
     * http://javascript.internet.com
     */
function jcv_checkEmail(emailStr) {
    if (emailStr.length == 0) {
        return true;
    }
    // TLD checking turned off by default
    var checkTLD=0;
    var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
    var emailPat=/^(.+)@(.+)$/;
    var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
    var validChars="\[^\\s" + specialChars + "\]";
    var quotedUser="(\"[^\"]*\")";
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
    var atom=validChars + '+';
    var word="(" + atom + "|" + quotedUser + ")";
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
    var matchArray=emailStr.match(emailPat);
    if (matchArray==null) {
        return false;
    }
    var user=matchArray[1];
    var domain=matchArray[2];
    for (i=0; i<user.length; i++) {
        if (user.charCodeAt(i)>127) {
            return false;
        }
    }
    for (i=0; i<domain.length; i++) {
        if (domain.charCodeAt(i)>127) {
            return false;
        }
    }
    if (user.match(userPat)==null) {
        return false;
    }
    var IPArray=domain.match(ipDomainPat);
    if (IPArray!=null) {
        for (var i=1;i<=4;i++) {
            if (IPArray[i]>255) {
                return false;
            }
        }
        return true;
    }
    var atomPat=new RegExp("^" + atom + "$");
    var domArr=domain.split(".");
    var len=domArr.length;
    for (i=0;i<len;i++) {
        if (domArr[i].search(atomPat)==-1) {
            return false;
        }
    }
    if (checkTLD && domArr[domArr.length-1].length!=2 && 
        domArr[domArr.length-1].search(knownDomsPat)==-1) {
        return false;
    }
    if (len<2) {
        return false;
    }
    return true;
}
    
//Captcha
function validarCaptcha(field) {
    var rValue = true;
    if(document.forms['login'].skill.value != "16") {
        rValue = false;
        if(field == "skill") {
            document.getElementById('msg_skill').innerHTML = "<b>That is not the right answer!</b>";
        }
    }
    else {
        document.getElementById('msg_skill').innerHTML = "";
    }
    return rValue;
}
//Borrar el texto de los inputText
function clearText(field)
{
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}